package com.codeyang.controller;

import com.codeyang.domain.Area;
import com.codeyang.service.AreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 描述: TO-删除标志-DO
 *
 * @author CodeYang_Site
 * @version 2021/5/27 9:35
 */
@Api(tags = "区域管理接口")
@RestController
@RequestMapping("admin/area")
public class AreaController {

    @Autowired
    private AreaService areaService;

    @GetMapping("list")
    @ApiOperation("区域列表全查询")
    public ResponseEntity<List<Area>> list() {

        List<Area> list = areaService.list();

        return ResponseEntity.ok(list);
    }

    @GetMapping("/listByPid")
    @ApiOperation("通过父区域id查询子区域-默认从全国最高等级遍历省份")
    public ResponseEntity<List<Area>> listByPid(@RequestParam(name = "pid", defaultValue = "0") Long pId) {
        List<Area> areas = areaService.listByPid(pId);
        return ResponseEntity.ok(areas);
    }


}
